/**
 * 图表线型数据统计控制器
 */
import tem from './index.html'
import './index.less'
import $_fn from '~plugins'
import G2 from 'g2'
class  chartsLineCtrl {
  constructor($scope) {
  	  console.log('-------')
  	 // $scope.kongZhiTai(fn1)
  	  var fn1=function(data){
  	  	  console.log('财务数据',data.data.entryTrend)
  	  	  console.log(data)
  	  	  console.log(data.data.entryTrend)
	  	  /*var data = [
	          {time: '07-14', data: 0},
	          {time: '07-15', data: 7.0},
	          {time: '07-16', data: 6.9},
	          {time: '07-17', data: 9.5},
	          {time: '07-18', data: 14.5},
	          {time: '07-19', data: 18.2},
	          {time: '07-20', data: 21.5}
	      ];*/
	      var chart = new G2.Chart({
	          id: 'charts_line',
	          forceFit: true,
	          height: 450,
	          plotCfg: {
	              margin: [40, 10, 60, 30]
	          }
	      });
	      chart.axis('count', {
	          title: null, // 去除 X 轴标题
	          labels:{
	              label: {
	                  fontSize: '14', // 文本大小
	              }
	          }
	      });
	      chart.axis('foundTime', {
	          title: {
	              fontSize: '14',
	              fill: '#333',
	          },
	          labels:{
	              label: {
	                  fontSize: '14', // 文本大小
	              }
	          }
	      });
	      /*chart.col('foundTime', {
			  formatter: function(val) {
			      return val + '元';
			  }
			});*/
	      chart.source(data.data.entryTrend, {
	          foundTime: {
	              alias: '30天进件趋势（笔）'
	          },
	          count: {
	              alias: '进件趋势'
	          }
	      });
	      chart.line().position('foundTime*count').color('#f3bc2e').size(2);
	      chart.render();
  	 }
  	  $scope.kongZhiTai(fn1)
  }
}


chartsLineCtrl.$inject = ['$scope','$rootScope','$timeout','$location','$interval']
module.exports = angular.module('directive.chartsLine', []).directive('chartsLine', function() {
    return {
        restrict: 'E',
        template: tem,
        replace:true,
        scope:'@',
        controller: chartsLineCtrl
    }
}).name